package com.example.classcommunity3.service;

import com.example.classcommunity3.dao.AdminDao;
import com.example.classcommunity3.model.Admin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class AdminService {

    @Autowired
    AdminDao adminDao;

    public HashMap<String, Object> login(Long account, String psw){

        HashMap<String, Object> hashMap = new HashMap<>();

        hashMap.put("character", "admin");
        hashMap.put("name", "admin");
        hashMap.put("account", account);
        Admin admin = adminDao.findByAAccount(account);
        if (admin == null) {
            hashMap.put("verify", false);
        } else {
            if (psw.equals(admin.getaPassword()))
                hashMap.put("verify", true);
            else
                hashMap.put("verify", false);
        }
        return hashMap;
    }
}
